//
//  ISProtectItemCollectionViewCell.m
//  iPhoneSafety
//
//  Created by dlon 2018/12/31.
//  Copyright © 2018年 com.li.ding. All rights reserved.
//

#import "ISProtectItemCollectionViewCell.h"
#import "UIColor+NWHex.h"
#import "NWLazyProperty.h"
#import <Masonry/Masonry.h>

@interface ISProtectItemCollectionViewCell()

@property (nonatomic, strong) UIImageView *statusImgView;

@end

@implementation ISProtectItemCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self.contentView addSubview:self.statusImgView];
        [self.contentView addSubview:self.tipLabel];
        self.isOn = NO;
        
        [self.statusImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.tipLabel).offset(-20.f);
            make.size.mas_equalTo(CGSizeMake(14.f, 14.f));
            make.centerY.equalTo(self.tipLabel);
        }];
        
        [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.contentView);
        }];
    }
    return self;
}


#pragma mark - set & get
NWLazyPropertyWithInit(UIImageView, statusImgView, {
    
})

NWLazyPropertyWithInit(UILabel, tipLabel, {
    _tipLabel.numberOfLines = 1;
})

- (void)setIsOn:(BOOL)isOn {
    _isOn = isOn;
    
    if (isOn) {
        self.tipLabel.textColor = [UIColor nw_colorWithHex:0xffffff];
        self.statusImgView.image = [UIImage imageNamed:@"img_protect_light_on"];
    } else {
        self.tipLabel.textColor = [UIColor nw_colorWithHex:0xffffff alpha:0.4];
        self.statusImgView.image = [UIImage imageNamed:@"img_protect_light_off"];
    }
}

@end
